import json

collinsfiles = [
    "../resource/json/collins1.json",
    "../resource/json/collins2.json",
    "../resource/json/collins3.json",
    "../resource/json/collins4.json",
    "../resource/json/collins5.json"
]

def how_many_words():
    words_count = 0
    for file in collinsfiles:
        f = open(file,"r",encoding='UTF-8')
        content = f.read()
        data = json.loads(content)
        words_count = len(data) +words_count
    return words_count

def get_ph_en(spelling):
    pronounce = None
    for file in collinsfiles:
        f = open(file,"r",encoding='UTF-8')
        content = f.read()
        data = json.loads(content)
        for i in data:
            if i['word'] == spelling:
                try:
                    pronounce = i['ph_en']
                except KeyError:
                    pass
        f.close()
    return pronounce


if __name__ == '__main__':
    print(how_many_words())

